package com.fileshare.web.controller.index.api;

import com.fileshare.web.dto.Result;
import com.fileshare.web.dto.Vo.UeditorConfigVo;
import com.fileshare.web.service.UeditorService;
import com.fileshare.web.service.UploadService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/api/ueditor")
@ResponseBody
public class UeditorApiController {
    @Resource
    private UploadService uploadService;
    @Resource
    private UeditorService ueditorService;

    @GetMapping("/action/config")
    public Result<UeditorConfigVo> uEditorConfig(HttpServletRequest request) {
        return Result.success().with(new UeditorConfigVo());
    }

    @PostMapping("/action/image")
    public Result<String> uEditorImage(@RequestParam(value = "image") MultipartFile file) {
        String url = uploadService.uploadFile(file);
        return Result.success().with(url);
    }

    @GetMapping("/action/listImage")
    public Result<String> uEditorListImage(HttpServletRequest request) {
        return Result.success().with();
    }

    @GetMapping("/action/video")
    public Result<String> uEditorVideo(HttpServletRequest request) {
        return Result.success().with();
    }

    @GetMapping("/action/file")
    public Result<String> uEditorFile(HttpServletRequest request) {
        return Result.success().with();
    }

    @GetMapping("/action/listFile")
    public Result<String> uEditorListFile(HttpServletRequest request) {
        return Result.success().with();
    }

    @GetMapping("/action/crawl")
    public Result<String> uEditorCrawl(HttpServletRequest request) {
        return Result.success().with();
    }
}
